//
// Created by shaowenhan on 2020/5/8.
//

#include "ConfigurableEventListener.h"
#include "ReadMDVRPInstance.h"
#if defined(MDVRP) or defined(MDOVRP)
class TestReadMDVRPInstance: public testing::Test{
public:
    ReadMDVRPInstance readInstance;
    Instance instance;
    TestReadMDVRPInstance():
    readInstance("../../Test/MDVRPInstance"),
    instance(readInstance.obtainInstance()){}
};
TEST_F(TestReadMDVRPInstance, ProblemName)
{
    ASSERT_EQ("../../Test/MDVRPInstance", instance.instanceName);
}
TEST_F(TestReadMDVRPInstance, ProblemType)
{
#if defined(MDVRP)
    ASSERT_EQ("MDVRP", instance.instanceType);
#elif defined(MDOVRP)
    ASSERT_EQ("MDOVRP", instance.instanceType);
#endif
}
#if defined(MDVRP)
TEST_F(TestReadMDVRPInstance, VehicleNumber)
{
    ASSERT_EQ(2, instance.tourNum);
}
#endif
TEST_F(TestReadMDVRPInstance, CustomerNumber)
{
    ASSERT_EQ(3, instance.cusNum);
}
TEST_F(TestReadMDVRPInstance, DepotNumber)
{
    ASSERT_EQ(2, instance.depotNum);
}
TEST_F(TestReadMDVRPInstance, NodeNumber) {
    ASSERT_EQ(5, instance.totalNodeNum);
}
TEST_F(TestReadMDVRPInstance, NonCusNodeNum) {
    ASSERT_EQ(2, instance.nonCusNodeNum);
}
#if defined(MDVRP)
TEST_F(TestReadMDVRPInstance, MaximalDurationTime)
{
    ASSERT_EQ(INT_MAX, instance.duration);
}
#endif
TEST_F(TestReadMDVRPInstance, MaximalLoad)
{
    ASSERT_EQ(80, instance.vehicleCap);
}
TEST_F(TestReadMDVRPInstance, Distance)
{
#if defined(MDVRP)
    vector<vector<double>> expectedDistance = {
            {0.0, 22.360679774997898, 36.235341863986875, 41.012193308819754, 54.405882034941776},
            {22.360679774997898, 0.0, 13.892443989449804, 21.02379604162864, 32.55764119219941},
            {36.235341863986875, 13.892443989449804, 0.0, 12.36931687685298, 19.209372712298546},
            {41.012193308819754, 21.02379604162864, 12.36931687685298, 0.0, 15.297058540778355},
            {54.405882034941776, 32.55764119219941, 19.209372712298546, 15.297058540778355, 0.0}
    };
#elif defined(MDOVRP)
    vector<vector<double>> expectedDistance = {
            {0.0, 22.360679774997898, 36.235341863986875, 41.012193308819754, 54.405882034941776},
            {22.360679774997898, 0.0, 13.892443989449804, 21.02379604162864, 32.55764119219941},
            {0, 0, 0.0, 12.36931687685298, 19.209372712298546},
            {0, 0, 12.36931687685298, 0.0, 15.297058540778355},
            {0, 0, 19.209372712298546, 15.297058540778355, 0.0}
    };
#endif

    ASSERT_EQ(expectedDistance, instance.distances);
}
#if defined(MDVRP)
TEST_F(TestReadMDVRPInstance, ServiceTimes)
{
    vector<int> expectedServiceTime = {
            0, 0, 0, 0, 0
    };

    ASSERT_EQ(expectedServiceTime, instance.serviceTimes);
}
#endif
TEST_F(TestReadMDVRPInstance, Demand)
{
    vector<int> expectedDemands = {
            0, 0, 7, 30, 16
    };

    ASSERT_EQ(expectedDemands, instance.nodeDemands);
}
#endif